Libraries
library(rvest)
## Loading required package: xml2
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(knitr)
setwd("C:/Users/perot/Desktop/NTU-CSX4001/Week_6&7&8(Project_1)")
Get Local data
rank = read.csv("RATE.csv",stringsAsFactors=FALSE)
rank$rankpoint = 21-rank$排行
url = read.csv("url.csv",stringsAsFactors=FALSE,header = F)
rate = read.csv("feature_rate.csv",stringsAsFactors=FALSE,header = T)
Get feature ranking
for(i in c(0:19)){
raw <- read_html(url$V1[i])
fea <- html_nodes(raw,"#BH-slave ul:nth-child(1) li")%>%html_text(raw)
per <- html_nodes(raw,".ACG-persent span ")%>%html_text(raw)
rate.i = data.frame(fea,per,stringsAsFactors=FALSE)
if(i == 1){
rate = data.frame(rate.i,stringsAsFactors=FALSE)
}
else{
rate = data.frame(rate,rate.i,stringsAsFactors=FALSE)
}
}
write.csv(rate,"feature_rate.csv")
數據呈現
kable(rank)
| 1 |
窟窿騎士 |
動作 |
Team Cherry |
2017/2/24 |
9.8 |
155 |
20 |
| 2 |
Undertale |
角色扮演 |
tobyfox |
2015/9/15 |
9.7 |
349 |
19 |
| 3 |
我的世界 |
其他 |
Mojang AB |
2009/5/17 |
9.6 |
11853 |
18 |
| 4 |
上古卷軸 5:無界天際 |
角色扮演 |
Bethesda Game Studios |
2011/11/11 |
9.6 |
2976 |
17 |
| 5 |
英雄傳說:碧之軌跡 |
角色扮演 |
Falcom |
2013/4/12 |
9.6 |
2176 |
16 |
| 6 |
巫師 3:狂獵 |
角色扮演 |
CD Projekt RED |
2015/5/19 |
9.6 |
1671 |
15 |
| 7 |
Little Busters! |
冒險 |
Visual Art’s/Key |
2007/7/27 |
9.6 |
776 |
14 |
| 8 |
CLANNAD |
冒險 |
Key |
2004/4/28 |
9.6 |
614 |
13 |
| 9 |
聖靈之光 |
冒險 |
Moon Studios GmbH |
2015/3/11 |
9.6 |
365 |
12 |
| 10 |
星露谷物語 |
角色扮演 |
ConcernedApe |
2016/2/27 |
9.6 |
359 |
11 |
| 11 |
Ever17:時光的羈絆(中文版) |
冒險 |
KID |
2004/1/8 |
9.6 |
284 |
10 |
| 12 |
幻想之詩 |
角色扮演 |
天使遊戲設計團隊 |
2013/9/6 |
9.6 |
267 |
9 |
| 13 |
魔法使之夜 |
冒險 |
Type-Moon |
2012/4/12 |
9.6 |
261 |
8 |
| 14 |
RPG 製作大師 MV |
其他 |
Kadokawa Games&Yoji Ojima |
2015/10/23 |
9.6 |
213 |
7 |
| 15 |
英雄傳說 空之軌跡 SE 終回特典 |
角色扮演 |
Falcom |
2011/12/20 |
9.6 |
192 |
6 |
| 16 |
史萊姆農場 |
策略模擬 |
Monomi Park |
2016/1/15 |
9.6 |
132 |
5 |
| 17 |
鋼鐵雄心 4 |
策略模擬 |
Paradox Development Studio |
2016/6/6 |
9.6 |
130 |
4 |
| 18 |
恆星戰役 |
策略模擬 |
Paradox Development Studio |
2016/5/9 |
9.6 |
97 |
3 |
| 19 |
俠盜獵車手 5 |
動作 |
Rockstar North |
2015/4/14 |
9.5 |
9488 |
2 |
| 20 |
英雄傳說 零之軌跡 |
角色扮演 |
Falcom |
2011/9/10 |
9.5 |
2441 |
1 |
遊戲的類別分布
#category
rank.an = rank
rank.an = rank.an %>%
group_by(類型) %>%
summarise(no_rows = length(類型))
plot_ly(rank.an, labels = ~類型,values = ~no_rows, type = 'pie') %>%
layout(title = '巴哈姆特PC遊戲評分前20類型比例',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
好遊戲不受時間影響,仍然屹立不搖
#released date
plot_ly(rank, x= ~發售日期 ,y= ~rankpoint, type = 'scatter',mode="markers",text = ~paste('遊戲名稱: ', 作品名稱))
玩家注重的東西
cou = c()
for(i in c(1:20)){
for(j in rate[[2*i-1]]){
cou = c(cou,j)
}
}
cou= as.factor(cou)
cou = data.frame(cou,c(1:100))
plot_ly(cou ,x= ~cou ,type = 'histogram')
cu = cou %>%
group_by(cou) %>%
summarise(freq = length(cou))
cu = arrange(cu, desc(freq))
plot_ly(cu, labels = ~cou,values = ~freq, type = 'pie') %>%
layout(title = '巴哈姆特PC遊戲評分前20遊戲特色比例',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))